<template>
  <div>
   
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="titleType" label="类型" width="150">
        <template slot-scope="scope">
          {{ questiontype(scope.row.titleType) }}
        </template>
      </el-table-column>
      <el-table-column prop="question" label="题目" width="250">
      </el-table-column>
      <el-table-column prop="answer" label="答案" width="292">
      </el-table-column>
      <el-table-column prop="iserror" label="是否答错" width="120">
        <!-- {{ questiontype(scope.row.iserror) }} -->
       <!-- <template>
     
    </template> -->
      </el-table-column>
      <el-table-column label="批改" width="120" align="center">
        <template slot-scope="scope">
          <!-- <el-button @click="handleClick(scope.row)" type="text"
            >查看</el-button
          > -->
          <el-button type="success" icon="el-icon-check" @click="startcorrect(scope.row)" circle></el-button>
          <el-button type="danger" icon="el-icon-close" @click="iserror(scope.row)" circle></el-button>
        </template>
      </el-table-column>
    </el-table>
     <el-button type="primary" @click="submit">完成批改</el-button>
  </div>
</template>
<script>
import qs from 'qs';
export default {
   data() {
    return {
        radio: "",
       tableData: [],
      type_question: ["选择题", "填空题", "解答题", "作文题"],
    
      tid: this.$store.state.conpletedid
      
       //
    };
  },
  methods: { //<el-input>框会出现无法输入消息的情况,这个方法绑定了@input,强制刷新
  //批改完成，提交
  submit(){
      console.log(this.tableData);
    
         this.$axios
        .get(
          "http://localhost:8080/selecttest",
          //完成作业ID
         {params:{list: this.tableData}},
    // qs.stringify({ids: [1, 2, 3]}, {arrayFormat: 'indices'})
        )
        .then((resp) => {
       // console.log(resp.data)
        
        // this.tableData=resp.data
        //  console.log(resp.data)
        });
  },
  //批改答案，正确
  startcorrect(row){
     console.log(row);
       row.iserror="对"
     
   },
   //判断作业类型
    questiontype(titleType) {
      return this.type_question[titleType - 1];
    },
     //批改答案，错误
   iserror(row){
 row.iserror="错"
   },
  //获取题目与答案
   correct(){
    //  console.log(this.tid)
      this.$axios
        .get(
          "http://localhost:8080/selecttest",
          //完成作业ID
           
          {params:{tid:this.tid,aa:"aa"}}
        )
        .then((resp) => {
       // console.log(resp.data)
        
        this.tableData=resp.data
      
        });
   }
  },

    mounted(){
      this.correct()
    }
};
</script>
<style scoped></style>
